import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/login/login.vue'
import Layout from '../views/layout/layout.vue'
import Search from '../views/search/search.vue'
import SearchResult from '../views/search/searchResult.vue'
import Article from '../views/article/article.vue'
Vue.use(VueRouter)

const routes = [
  // {
  //   path: '/',
  //   name: 'Home',
  //   component: Home
  // },
  {
    path: '/Login',
    name: 'Login',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/login/login.vue')
  },
  {
    path: '/', // 主页
    name: 'Layout',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "layout" */ '../views/layout/layout.vue'),
    // 二级路由
    children: [
      {
        path: '/home',
        name: 'home',
        component: () => import(/* webpackChunkName: "layout" */ '../views/home/home.vue')
      },
      {
        path: '/question',
        name: 'question',
        component: () => import(/* webpackChunkName: "layout" */ '../views/question/question.vue')
      },
      {
        path: '/video',
        name: 'video',
        component: () => import(/* webpackChunkName: "layout" */ '../views/video/video.vue')
      },
      {
        path: 'setting',
        name: 'setting',
        component: () => import(/* webpackChunkName: "layout" */ '../views/setting/setting.vue')
      }
    ]
  },
  {
    path: '/search', // 搜索页
    name: 'search',
    component: () => import(/* webpackChunkName: "layout" */ '../views/search/search.vue')
  },
  {
    path: '/SearchResult', // 搜索结果页
    name: 'SearchResult',
    component: () => import('../views/search/searchResult.vue')
  },
  {
    path: '/article/:id', // 动态路由
    name: 'article',
    component: () => import('../views/article/article.vue')
  }
]

const router = new VueRouter({
  routes,
  Login,
  Layout,
  Search,
  SearchResult,
  Article
})

export default router
